package com.ruoyi.system.view.common;

import java.io.Serializable;
import java.util.List;

public class ResultList<T> implements Serializable {
    private Integer code = 200;
    private String msg;
    private T rows;
    private Integer total;

    public static <T> ResultList<T> success(T object,Integer total, String msg) {
        ResultList<T> r = new ResultList<T>();
        r.rows = object;
        r.msg = msg;
        r.total = total;
        return r;
    }
    public static <T> ResultList<T> error(T object,Integer total, Integer code, String msg) {
        ResultList<T> r = new ResultList<T>();
        r.rows = object;
        r.msg = msg;
        r.total = total;
        r.code = code;
        return r;
    }

    @Override
    public String toString() {
        return "ResultList{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", rows=" + rows +
                ", total=" + total +
                '}';
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<T> getRows() {
        return (List<T>) rows;
    }

    public void setRows(List<T> rows) {
        this.rows = (T) rows;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }
}
